package com.hmall.api.FallbackFactory;

import com.hmall.api.CartClient;
import com.hmall.api.ItemClient;
import com.hmall.common.exception.BizIllegalException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.Collection;

public class CartFallbackFactory implements FallbackFactory<CartClient> {
    private static final Logger log = LoggerFactory.getLogger(CartFallbackFactory.class);

    @Override
    public CartClient create(Throwable cause) {
        return new CartClient(){

            @Override
            public void removeByItemIds(Collection<Long> ids) {
                log.error("调用CartClient.removeByItemIds()方法失败", cause);

                throw new BizIllegalException(cause);
            }
        };
    }
}
